/* $Id: module.h,v 1.1 2006/03/19 20:13:52 jfb Exp $ */
/*
 * Copyright (c) 2003 Jean-Francois Brousseau <jfb@fugusec.net>
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. The name of the author may not be used to endorse or promote products
 *    derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
 * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */


#ifndef MODULE_H
#define MODULE_H

#include <sys/types.h>
#include <sys/queue.h>


#include <EXTERN.h>
#include <perl.h>


#define PERL_MOD_INITSUB     "init"
#define PERL_MOD_CLEANUPSUB  "cleanup"


/* module flags */
#define PERLMOD_LOADED       0x01
#define PERLMOD_INITDONE     0x02
#define PERLMOD_CLEANUPDONE  0x04
#define PERLMOD_PARSED       0x08




struct perl_mod {
	u_int  mod_id;
	char   mod_name[64];
	char   mod_path[_POSIX_PATH_MAX];

	u_int  mod_flags;

	/* Perl interpreter used to run this module */
	PerlInterpreter *interp;

	TAILQ_ENTRY(perl_mod) mod_link;
};


int              mod_perl_modinit  __P((void));


/* Perl module API */
struct perl_mod*       perlmod_load      __P((const char *));
const struct perl_mod* perlmod_find      __P((const char *));
int                    perlmod_unload    __P((struct perl_mod *));
int                    perlmod_parse     __P((struct perl_mod *));

int                    perlmod_init      __P((struct perl_mod *));
int                    perlmod_cleanup   __P((struct perl_mod *));

#endif /* MODULE_H */
